﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace XMLSQL.Admin
{
    public partial class ResetPassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MembershipUserCollection members = Membership.GetAllUsers();
            members.Remove(User.Identity.Name);
            foreach (MembershipUser u in members)
            {
                resetListBox.Items.Add(u.UserName);
            }
        }

        protected void resetButton_Click(object sender, EventArgs e)
        {
            //do something here
            var user = Membership.GetUser(resetListBox.SelectedItem.Text);
            user.ChangePassword(user.ResetPassword(), resetTextBox.Text.Trim());
            Membership.UpdateUser(user);

            //return to the admin page
            Response.Redirect("~/Admin/CRUDUser.aspx");

        }
    }
}